<?php
/**
 * Created by PhpStorm.
 * User: a
 * Date: 2016/6/7
 * Time: 17:32
 */
namespace Admin\Model;
use Think\Model;

class InvestDetailModel extends Model 
{
    protected $trueTableName = 'bypal_invest_detail';


    /**
	 * 投资管理详情页数据
	 */
	public function get_invest_detail($invest_id) 
	{
		$select_sql = "select t1.invest_id,t2.cust_name,t1.invest_rate,sum(t1.invest_money) invest_money,t1.invest_time,t1.customer_id,t1.invest_detail_id 
				from bypal_invest_detail t1 
				left join bypal_cust_info t2 on t1.customer_id=t2.cust_id 
				where t1.invest_id=".$invest_id." 
				group by t1.invest_id,t1.invest_repay_id,t1.customer_id";
		$Model = new \Think\Model();
		$values = $Model->query($select_sql);

		return $values;
	}

    /**
     * 查询客户的投资详情
     * @param $cust_id
     * @return mixed
     */
    public function get_invest_detail_bycustid($cust_id){
        $select_sql = "select t1.invest_id,t1.invest_rate,t1.invest_money,t1.invest_time,t1.invest_detail_id,
        t2.invest_title,round(t2.invest_time_limit/30) invest_time_limit,t3.invest_status_name
				from bypal_invest_detail t1
				left join bypal_invest_project t2 on t1.invest_id=t2.invest_id
				left join bypal_invest_status t3 on t1.invest_status=t3.detail_status_id
				where t1.customer_id=".$cust_id;
        $Model = new \Think\Model();
        $values = $Model->query($select_sql);

        return $values;
    }
}